/* 
 * Copyright (c)	Insighten Intelligent Equipment co.,LTD
 * 
 *  Use of this software is controlled by the terms and conditions found
 *  in the license agreement under which this software has been supplied.
 * 
 */
#ifndef RWBUF_H_
#define RWBUF_H_

struct _RwBuf;
typedef struct _RwBuf RwBuf;

typedef int (*FunMemAlloc)(int size);
typedef char* (*FunMemFree)(char *mem);

struct _RwBuf {
	struct _RwBuf *prev;
	struct _RwBuf *next;
	char *mem;
	unsigned int rpos;
	unsigned int wpos;
	unsigned int totalsize;
	FunMemAlloc mem_alloc;
	FunMemFree mem_free;
};

RwBuf *buf_new(FunMemAlloc alloc, FunMemFree mfree);
int buf_destroy(RwBuf *thiz);
int buf_init(RwBuf *thiz, int size);
int buf_update_wpos(RwBuf *thiz, int size);
int buf_update_rpos(RwBuf *thiz, int size);
#endif /*RWBUF_H_*/
